<?php
class buyPaypal
{
	public static function findPaypalAgent()
	{
		$getPaypalAgent=database::LimitQuery("agent",array(
		'select' => 'agent_class,agent_name',
		'condition' => array(
		'enable' => 'Y',
		'agent_type' => 'paypal'
		)
		));
		$returnAgent=NULL;
		foreach($getPaypalAgent as $paypalAgent)
		{
			$agent=$paypalAgent['agent_class'];
			$agentName=$paypalAgent['agent_name'];
			$returnAgent="<option value='$agent'>$agentName</option>".$returnAgent;
		}
		$returnAgent="<option value=''>Choose Agent</option>".$returnAgent;
		return $returnAgent;
	}
	public static function findPaypalCountry($agent)
	{
		$checkVerify=verify::check($agent);
		if($checkVerify=="0")
		{
			$getPaypalCountryMrhieu=database::LimitQuery("paypal_country",array(
			'select' => 'country_code,country_name',
			'condition' => array(
			'agent_class' => $agent
			)
			));
			$returnResult=NULL;
			foreach($getPaypalCountryMrhieu as $listCountry)
			{
				$country_code=$listCountry['country_code'];
				$country_name=$listCountry['country_name'];
				$returnResult="<option value='$country_code'>$country_name</option>".$returnResult;
				
			}
			$returnResult="Country<select name='paypalCountry' id='paypalCountry' ><option value=''>All</option>".$returnResult."</select>";
			return $returnResult;
		}
		else
		{
			return 0; // mistake
		}
	}
	public static function getMrhieuPrice($paypalId)
	{
		
		foreach($paypalId as $listId)
		{
			$listPaypalId[]=$listId;
		}
		$condition=database::BuildCondition(array(
		'id' => $listPaypalId
		));
		$getPrice=database::LimitQuery("paypal",array(
		'select' => 'sum(sell_price)',
		'condition' => $condition
		));
		return $getPrice[0]['sum(sell_price)'];
	}
	public static function plusmoney($paypalType,$haveMailPass)
	{
		$plusMoney=NULL;
		if(($paypalType !="personal")&&(!empty($paypalType)))
		{
			
			$plusMoney=$plusMoney+1;
		}
		if($haveMailPass=="yes")
		{
			$plusMoney=$plusMoney+1;
		}
		return $plusMoney;
	}
}

?>